package web.day02;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DemoCount extends HttpServlet{
 
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 整个web应用里面，只有一个servletContext对象，在服务器启动时被创建
		//在服务器关闭的时候被清除
		ServletContext context=getServletContext();
		ServletConfig config=getServletConfig();
		
		config.getInitParameter("");
		context.getInitParameter("");
		
		System.out.println("context:"+context);
		
		Integer count=(Integer)context.getAttribute("count");
		
		if(count==null) {
			context.setAttribute("count", 1);
		}else {
			context.setAttribute("count", count+1);
		}
		System.out.println(count);
	}
}
